load("02_09_m5s_join_user_activity_df_univ_only.RData")

load("02_09_m5s_join_behav_order_activities")

univ_ids_moved_to_mu <- 
  order_of_activities$action2 == "meetup" |
  order_of_activities$action3 == "meetup" |
  order_of_activities$action4 == "meetup"
univ_ids_moved_to_mu[is.na(univ_ids_moved_to_mu)] <-FALSE
univ_ids_moved_to_mu <- order_of_activities$universal_id[univ_ids_moved_to_mu]

moved_to_mu_df <- subset(join_user_activity_df_univ_only, universal_id %in% univ_ids_moved_to_mu)

require(ggplot2)
require(scales)
require(data.table)

max(as.numeric(table(moved_to_mu_df$universal_id)))

sample_ids <- sample(unique(moved_to_mu_df$universal_id), 1000)
sbst <- subset(moved_to_mu_df, universal_id %in% sample_ids)

diff_from_join <- subset(sbst, activity %in% c("rsvp","post","comment","like"))

first_event <- data.table(subset(diff_from_join, activity=="rsvp"))
first_event <- as.data.frame(first_event[,list(first_event = min(date)),by=universal_id])

diff_from_join <- merge(diff_from_join, first_event, by="universal_id", all=TRUE)

diff_from_join$diff_from_join <- diff_from_join$date - diff_from_join$first_event


ggplot(diff_from_join, aes(y=universal_id, x=diff_from_join, colour=activity)) + 
  geom_point(size=2, alpha=.3) + theme(axis.text.y=element_blank())